1. Field of the Invention
The present invention relates to an image decoding method, and more particularly to a method for progressive JPEG image decoding.
2. Description of Related Art
Joint Photographic Experts Group (JPEG) compression technology on the basis of progressive discrete cosine transformation (DCT) encodes the whole image by scanning for a plurality of times such that the encoded JPEG data stream includes data of a plurality of scan layers. Therefore, during the process of decoding, the data of the plurality of scan layers must be decoded to re-establish the original image, and since one part of the characteristics of the original image is recorded in each scan layer, the image decoded from each scan layer roughly presents the original image, and the image definition will be enhanced as the number of the decoded scan layers increases.
FIG. 1 shows a conventional progressive JPEG decoding device. Referring to FIG. 1, the decoding device 100 includes a variable length decoding (VLD) device 110, a memory device 120, an inverse quantizer 130 and an inverse DCT device 140. The decoding process on the basis of progressive DCT needs to be processed through the above devices, and the flow is described as follows.
First, the encoded JPEG data is processed by the VLD device 110. When each scan layer is processed by the VLD device 110, the information of the previous scan layer is required as a reference, thus, the processing result must be stored in the memory device 120 having the same size with the image, which is used as a reference for processing the next scan layer by the VLD device 110. When the memory device 120 has collected all coefficients of a scan layer, the coefficients are sequentially sent to the inverse quantizer 130 and the inverse DCT device 140 to perform inverse quantizing process and inverse DCT process, so as to obtain decoded pixels and re-establish a progressive image.
If the above progressive JPEG image decoding device and the operating method thereof are applied to control a decoder, that is, controlling a decoding unit with a control system and decoding bitstream data into image data, a memory having the same size with the picture to be decoded is required to achieve the image decoding effect. FIG. 2 is a block diagram of a control system of a conventional decoder, and FIG. 3 is a flow chart of a conventional method for controlling a decoder. Referring to FIG. 2 first, a control system 200 includes a control unit 210, a data unit 220, a decoding unit 230, and a memory 240, wherein the control unit 210 is individually connected to the data unit 220 and the decoding unit 230, and the decoding unit 230 is further connected to the memory 240. The size of the memory 240 must be the same as that of the picture to be decoded, such that the memory 240 can be used to store the decoding result as the reference information during the decoding process.
Referring to both FIG. 2 and FIG. 3, the state of the control unit 210 at the very beginning is set to be an Initial state, and in Step S301, the control unit 210 sends a reset instruction to the decoding unit 230, and the decoding unit 230 resets its internal state and empties the memory 240.
In Step S302, the control unit 210 sends a data require instruction to the data unit 220, and then, the data unit 220 transmits the bitstream data to the decoding unit 230. At the same time, the control unit 210 further sends a decode instruction to the decoding unit 230 that sequentially receives the bitstream data from the data unit 220 to perform decoding, and the decoding coefficients generated during the decoding are stored in the memory 240, and at this time, the control unit 210 is at a Decode state.
In Step S303, when the decoding unit 230 has decoded all the bitstream data, the decoding unit 230 is switched to a Finish state. At this time, the control unit 210 knows that all the decoding flows have been completed. If there is no data in the data unit 220, the decoding unit is switched to a Data_empty state, and at this time, the control unit 210 sends a new data require instruction to the data unit 220. When the data transmission of the data unit 220 is resumed, the decoding unit 230 is switched to the Decode state to continue decoding. Moreover, if a decoding error occurs when decoding by the decoding unit 230, the decoding unit 230 is switched to an Error state, and then, the control unit 210 determines the method for processing the error. The above method for progressive JPEG decoding and the method for controlling the decoder may possess the feature of progressive image displaying, but the size of the decodable image is limited by the memory space.
US Patent No. 2003/0091240 has disclosed a progressive JPEG decoding method, which includes the following steps: receiving data of a scan layer of a JPEG image data, and dividing the scan layer into a plurality of areas; selecting one of the areas as a local decoding area; decoding the scan layer, wherein a plurality of decoding coefficients is generated according to the data of the local decoding area, and non-zero historic records of the other areas directing to the decoding coefficients are generated according to the data of the other areas except the local decoding area, and the initial addresses in the JPEG bitstream are also generated; and storing the generated results in the memory as the reference data for the subsequent decoding of other areas. The important feature of this method lies in dividing the progressive JPEG image into different areas, decoding one area each time; and decoding another area after the decoding of the previous one is completed, wherein the size of the decoding area may be adjusted according to the size of the memory, and the decoding process can be performed without disposing a memory having the same size as that of the image. However, a large amount of non-zero historic records and the initial addresses of each area must be recorded, which still occupies a large memory space.